#include <stdio.h> 
 const int x = 6; //global  in scope & cannot be changed   
 //initialise variables
 void populateData(int* dataArray, int sz); // we need three functions to enable the calculations/ dispalys 
 void workAve(int* dataArray, int sz); 
 void workVar(int* dataArray, int sz); // pointers 
 //assign 
 double mean = 0; 
 double var = 0; 
 
 int main (int argc, char** argv) {        
    //local visible that is modifiable only inside main         
 
 int intarray [x];                  
 
 populateData(intarray, x);         
 workAve(intarray, x);            
 workVar(intarray, x);         

 printf("The mean is %lf\n ", mean);         
 printf("The variance is %lf\n ", variance);          
 return 0;  
 } 
 void populateData(int* dataArray, int sz) // populate the data
 {         
 for(int i = 0; i < sz; i++)        
 {                
 dataArray[i] = i;         
 } 
  void workAve(int* dataArray, int sz) {     // calculate the mean first    
  double temp;         
  for(int i = 0; i < sz; i++){                 
  temp = temp + dataArray[i];        
  }         
  mean = temp/x; 
  }  
  void workVar(int* dataArray, int sz) {   // then calculate  the variable       
  double temp1;            
  double total; 
  for(int i = 0; i < sz; i++)  {                
  emp1 = dataArray[i] - mean;                 
  temp1 = temp*temp1;                 
  total = total + temp1;         
  }         
  variance = total/(x); 
  }  
